using System;
using System.Collections.Generic;
using System.ComponentModel;
using OpenFlashChartLib.Json;

namespace OpenFlashChartLib.Charts
{
    public interface IChart
    {
        double GetMinValue();
        double GetMaxValue();
        int GetValueCount();
    }

    public abstract class ChartBase : IChart
    {
        public abstract double GetMinValue();
        public abstract double GetMaxValue();
        public abstract int GetValueCount();
        public abstract IList<ILabelValue> Values { get; set; }
        public abstract ILabelValue NewValue();
        public abstract ILabelValue NewValue(string label, double value);

        protected ChartBase()
        {
            Fillalpha = 0.35;
        }

        public virtual bool X_AxisSpecified
        {
            get { return true;}
        }

        public virtual bool Y_AxisSpecified
        {
            get { return true; }
        }


        [JsonProperty("colour")]
        public virtual string Colour { set; get; }

        [JsonProperty("font-size")]
        [DefaultValue(12.0)]
        public double Fontsize { get; set; }

        [JsonProperty("text")]
        public string Text { get; set; }

        [JsonProperty("fillalpha")]
        public double Fillalpha { get; set; }

        [JsonProperty("type")]
        public string ChartType { get; protected set; }

        public virtual void BuildLabels(XAxis xAxis, YAxis yAxis)
        {
            if (!xAxis.HasLabelsChanged())
            {
                foreach (var value in Values)
                {
                    xAxis.Labels.Labels.Add(value.Label);
                }
            }
        }

    }
}